#include("/template/common/layout/_page_layout_all.html")
#@layout()

#define css()
<style>
    .layui-input-inline p {
        line-height: 20px;
    }

    .layui-form-pane .layui-form-text .layui-input-block, .layui-row {
        margin-top: 20px;
    }

    .layui-input-block input {
        width: 100%;
    }
</style>
#end

#define js()
<script type="text/javascript">
    layui.use(['form', 'layer', 'layedit', 'element'], function () {
        var $ = layui.jquery,
            layedit = layui.layedit,
            form = layui.form,
            layer = layui.layer;
        var riskFactorText = "#(riskFactor)";
        var resolvingText = "#(resolving)";
        var otherCommentsText = "#(otherComments)";

        if (riskFactorText !== "") {
            var ris = $('#riskFactor');
            ris.text(riskFactorText).css("display", "").removeClass("layui-hide");
        }
        if (resolvingText !== "") {
            var res = $('#resolving');
            res.text(resolvingText).css("display", "").removeClass("layui-hide");
        }
        if (otherCommentsText !== "") {
            var oth = $('#otherComments');
            oth.text(otherCommentsText).css("display", "").removeClass("layui-hide");
        }
        var option = {
            tool: [
                'strong'
                , 'italic'
                , 'underline'
                , 'del'
                , '|'
                , 'left'
                , 'center'
                , 'right'
                , 'link'
                , 'unlink'
            ]
        };

        /**
         * 增加行，已废弃
         */
            // $('.addRow').click(function (e) {
            //     var block = $(this).parents(".layui-input-block");
            //     var row = $('<div class="layui-row"></div>');
            //     var inp = $('<div class="layui-col-md10"><input type="text" id="facAgency.address" name="' + $(this).attr("data-name") +'" class="layui-input" required/></div>');
            //     var btn = $('<div class="layui-col-md2"><button type="button" class="layui-btn layui-btn-danger delRow" >删除</button></div>');
            //     row.append(inp).append(btn).appendTo(block);
            // });
            // $(document).on('click', '.delRow', function (e) {
            //     $(this).parents('.layui-row').remove();
            // });


        var riskFactor = layedit.build('riskFactor', option);
        var resolving = layedit.build('resolving', option);
        var index = layedit.build('otherComments', option);

        var select = "";
        form.on('select', function (data) {
            select = data.value;
        });

        $('#save').click(function (obj) {
            if (select === "" && $('.layui-select-tips').length > 0) {
                layer.msg("请选择专家！");
                return false;
            } else {
                var data = {
                    riskFactor: layedit.getContent(riskFactor),
                    resolving: layedit.getContent(resolving),
                    content: layedit.getContent(index),
                    projectID: "#(projectID)",
                    expertGroupId: select
                };
                var id = "#(thisId)";
                if (id !== null && id !== "") {
                    data.id = id;
                    data.expertGroupId = $('dd.layui-this').attr("lay-value");
                }
                var bg = $('<div class="loading-bg"><i class="layui-icon layui-icon-loading layui-icon layui-anim layui-anim-rotate layui-anim-loop loading-ico"></i></div>');
                $('body').prepend(bg);
                util.sendAjax({
                    type: 'POST',
                    url: '#(ctxPath)/app/information/expertAdvicePost',
                    data: data,
                    loadFlag: true,
                    success: function () {
                        $('.loading-bg').remove();
                        setTimeout(function () {
                            window.location.href = document.referrer;
                        }, 1000);
                    },
                    error: function () {
                        layer.msg("保存失败");
                    }
                })
                return false;
            }
        });


        $('#back').click(function (obj) {
            window.location.href = document.referrer;
        });
        var flag = '#(flag)';
        if (flag === "true") {
            $('#save').remove();
            $('input').addClass('layui-disabled').attr("disabled","disabled");
        }

    });
</script>
#end

#define content()
<div class="layui-fluid ">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;color: #009688">
        <legend>社会稳定风险评估现场踏勘专家意见表</legend>
    </fieldset>

    <form class="layui-form x-center" action="">
        <div class="layui-form-pane">
            <div class="layui-row">
                <div class="layui-col-md4">
            <div class="layui-form-item">
                <label class="layui-form-label">制表单位</label>
                <div class="layui-input-inline">
                    <input type="text" id="name" name="name" value="#(name)"
                           class="layui-input" readonly/>
                </div>
            </div></div>

                <div class="layui-col-md4">
            <div class="layui-form-item">
                <label class="layui-form-label">日期</label>
                <div class="layui-input-inline">
                    <input type="text" id="date" name="date" value="#(date)"
                           class="layui-input" readonly/>
                </div>
            </div></div>
                <div class="layui-col-md4">
            <div class="layui-form-item">
                <label class="layui-form-label" for="select">请选择专家</label>
                <div class="layui-input-inline">
                    <select name="expertGroup" lay-filter="aihao" id="select">
                        #if(expertGroup != null)
                        <option value="#(expertGroup.id)" selected="selected">#(expertGroup.name)</option>
                        #else
                        <option value="" selected="selected">请选择专家</option>
                        #end
                        #for(e : expertGroups)
                        <option value="#(e.id)">#(e.name)</option>
                        #end
                    </select>
                </div>
            </div></div>
            </div>

            <div class="layui-form-item layui-form-text">
                <div class="layui-input-block">
                    <label class="layui-form-label" for="riskFactor">项目建设可能存在的风险因素</label>
                    <textarea id="riskFactor" style="display: none;"></textarea>
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <div class="layui-input-block">
                    <label class="layui-form-label" for="resolving">应采取的相应化解措施</label>
                    <textarea id="resolving" style="display: none;"></textarea>
                </div>
            </div>


            <div class="layui-form-item layui-form-text">
                <div class="layui-input-block">
                    <label class="layui-form-label" for="otherComments">其它意见（建议）</label>
                    <textarea id="otherComments" style="display: none;"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="button" class="layui-btn" id="save">保存</button>
                    <button type="button" class="layui-btn layui-btn-warm" id="back">返回</button>
                </div>
            </div>
        </div>
    </form>
</div>

#end